using System;
using System.ComponentModel;
using System.Linq;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ApiTest.Entitys
{
    /// <summary>
    /// 商品属性
    /// </summary>  
    /// <remarks>
    /// <![CDATA[ENGINE=InnoDB  COMMENT='商品属性']]>
    /// </remarks>
    [DbSource("Default"), Serializable]
    public class GoodsAttribute
    {
        /// <summary>
        /// 属性ID
        /// </summary>
        /// <remarks>
        /// <![CDATA[int NOT NULL COMMENT '属性ID']]>
        /// </remarks>
        [Primary(Automatic = true)]
        [DisplayName("属性ID")]
        public int AttributeId { get; set; }

        /// <summary>
        /// 属性名称
        /// </summary>
        /// <remarks>
        /// <![CDATA[varchar(64) DEFAULT NULL COMMENT '属性名称']]>
        /// </remarks>
        [Column(64)]
        [DisplayName("属性名称")]
        public string AttributeName { get; set; }

        [JsonConverter(typeof(AutoEnumConverter))]
        public AttributeTypeEnum AttributeTypeName => (AttributeTypeEnum)AttributeType;

        /// <summary>
        /// 控件类型 [文本,多行文本,日期,单选项,多选项,开关]
        /// </summary>
        /// <remarks>
        /// <![CDATA[int NOT NULL COMMENT '控件类型 [文本,多行文本,日期,单选项,多选项,开关]']]>
        /// </remarks>
        [Column(false)]
        [DisplayName("控件类型")]
        public int AttributeType { get; set; }

        /// <summary>
        /// 属性说明
        /// </summary>
        /// <remarks>
        /// <![CDATA[varchar(128) DEFAULT NULL COMMENT '属性说明']]>
        /// </remarks>
        [Column(128)]
        [DisplayName("属性说明")]
        public string Tips { get; set; }

        /// <summary>
        /// 默认值组
        /// </summary>
        /// <remarks>
        /// <![CDATA[json DEFAULT NULL COMMENT '默认值组']]>
        /// </remarks>
        [Column]
        [DisplayName("默认值组")]
        public JToken DefaultValues { get; set; }

        /// <summary>
        /// 是否必填
        /// </summary>
        /// <remarks>
        /// <![CDATA[bit(1) NOT NULL COMMENT '是否必填']]>
        /// </remarks>
        [Column(1, false)]
        [DisplayName("是否必填")]
        public bool IsRequired { get; set; }

        /// <summary>
        /// 是否显示在商品筛选项目中
        /// </summary>
        /// <remarks>
        /// <![CDATA[bit(1) NOT NULL COMMENT '是否显示在商品筛选项目中']]>
        /// </remarks>
        [Column(1, false)]
        [DisplayName("是否显示在商品筛选项目中")]
        public bool IsFilter { get; set; }

        /// <summary>
        /// 是否删除 ***
        /// </summary>
        /// <remarks>
        /// <![CDATA[bit(1) NOT NULL COMMENT '是否删除 ***']]>
        /// </remarks>
        [JsonIgnore]
        [Column(1, false)]
        [DisplayName("是否删除")]
        public bool IsDel { get; set; }

        /// <summary>
        /// 显示排序
        /// </summary>
        /// <remarks>
        /// <![CDATA[int NOT NULL COMMENT '显示排序']]>
        /// </remarks>
        [Column(false)]
        [DisplayName("显示排序")]
        public int Sort { get; set; }

    }
}
